<layout name="Iflayout"/>
<div class="xyh-content">

    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em>
                会员列表
            </h3>
        </div>

    </div>

    <div class="row margin-botton">
        <div class="col-sm-6 column">
            <div class="btn-group btn-group-md">
                <button class="btn btn-primary" type="button" onclick="goUrl('add')"><em class="glyphicon glyphicon-plus-sign"></em> 添加会员</button>
                <button class="btn btn-default" type="button"><em class="glyphicon glyphicon-remove-circle"></em> 删除</button>
            </div>
        </div>
        <div class="col-sm-6 text-right">
            <form class="form-inline" method="post" action="">
                <div class="form-group">
                    <label class="sr-only" for="inputKeyword">关键字</label>
                    <input type="text" class="form-control" name="keyword" id="inputKeyword" placeholder="关键字" value="{$key}">
                </div>
                <button type="submit" class="btn">搜索</button>
            </form>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <form action="" method="post" id="form_do" name="form_do">
                <div class="table-responsive">
                    <table class="table table-hover xyh-table-bordered-out">
                        <thead>
                        <tr class="active">
                            <th><input type="checkbox" id="check"></th>
                            <th>编号</th>
                            <th>邮箱</th>
                            <th>昵称</th>
                            <th>会员组</th>
                            <th>登录时间</th>
                            <th>登录ip</th>
                            <th>状态</th>
                            <th class="text-right">操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <foreach name="list" item="arr">
                        <tr>
                            <td><input type="checkbox" name="key[]" value="{$arr['id']}" class="inputcheckbox"></td>
                            <td>{$arr['id']}</td>
                            <td>{$arr['email']}</td>
                            <td>{$arr['nickname']}</td>
                            <td>{$arr['name']}</td>
                            <td>{$arr['logintime']|date='Y-m-d H:i:s',###}</td>
                            <td>{$arr['loginip']}</td>
                            <td><span class="{$arr['islock'] ? 'label label-default':'label label-success'}">{$arr['islock'] ? '锁定':'正常'}</span></td>
                            <td class="text-right">
                                <a href="{:U('person',array('id'=>$arr['id']))}" class="label label-info">详情</a>
                                <a href="{:U('edit',array('id'=>$arr['id']))}" class="label label-success">编辑</a>
                                <a href="javascript:void(0)"  m="{$arr['id']}" class="label label-danger">删除</a>
                            </td>
                        </tr>
                        </foreach>

                        </tbody>
                    </table>
                </div>
            </form>

            <div class="row clearfix">
                <div class="col-md-12 column">
                    <div class="xyh-page">
                        <div><span class="rows">共{$count}条记录</span></div>
                        <div>{$page}</div>
                    </div>

                </div>
            </div>

        </div>
    </div>



</div>
</body>
</html>
<script>
    $(function(){

        $('.label-danger').click(function(){

            if(confirm('确定删除?')){

                var _id = $(this).attr('m');

                var _this = $(this);

                $.post("{:U('del')}", {id:_id}, function(data){

                    if(data){

                        alert('删除成功');

                        _this.parent().parent().remove();

                    }else{

                        alert('删除失败');
                    }

                })

            }

        })

    })

    $('.btn-default').click(function(){

        if ($('.inputcheckbox:checked').length==0 ) {

            alert('至少选择一个');

        }else{

            var arr = [];

            $('.inputcheckbox:checked').each(function(i){

                arr[i]=$(this).val();

            })

            if (confirm('确定删除？')) {

                $.post("{:U('del')}",{id:arr},function(data){

                    if (data==1) {

                        alert('删除成功');

                        $('.inputcheckbox:checked').parent().parent().remove();

                    }else{

                        alert('删除失败');

                    }

                })

            }

        }

    })

</script>